/*  mudmap - A tool to create and organize user side maps for MUD games
 *  Copyright (C) 2012  Neop (aka moemneop, email: mneop@web.de)
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 *  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 *  for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, see <http://www.gnu.org/licenses/>.
 */

/*  File description
 *
 *  The config class can read and save simple configuration files
 *  a key may only exist once
 */

#pragma once

#include <map>
#include <cstdlib>

#include "fileio.h"

using std::map;

/// Liest und schreibt einfache, schlüsselbasierte Konfigurationsdateien
class config{
    public:
        config(string file = "", char separator = '=');
        ~config();

        /// Liest die Konfigurationsdatei ein
        void read(string file, char separator);
        void read(string file = "");
        void write(string file = "");

        string file;
        char separator;

        bool get_bool(string key, bool def = false);
        int get_int(string key, int def = 0);
        float get_float(string key, float def = 0);
        char get_char(string key, char def = '-');
        string get_string(string key, string def = "");

        void set_bool(string, bool);
        void set(string, int);
        void set(string, float);
        void set(string, double);
        void set(string, char);
        void set(string, string);
    private:
        map<string, string> config_lines;
};
